Kettle = cc.Node.extend({

	ctor:function(parent,tag){
		this._super();
		parent.addChild(this,9,TAG_KETTLE_NODE);
		this.init();
	},
	init:function(tag){
		var kettle = new Button(this, 10, TAG_KETTLE,"#kettle.png", this.callback);
	

	},
	callback:function(p){
		var action = gg.flow.flow.action;
		var func = cc.callFunc(this.actionDone, this);	
		func.retain();
		var hand = new Hand();
		//hand.addrighthand(this, "#hand/hand_left", cc.p(-25,-25),0.6);
		switch(p.getTag()){
		case TAG_KETTLE:
			if(action==K1){
				
				var ber = cc.bezierBy(1.5, [cc.p(200,-210),cc.p(-50,-210),cc.p(-10,-190)]);
				var rotate = cc.rotateTo(1.5, -60);
				var spawn = cc.spawn(ber,rotate);
				var delay = cc.delayTime(1.5);
				var moveBack = cc.moveBy(1,cc.p(10,190));
				var rotate = cc.rotateTo(1, 0);
       
				
				var cylinder1node = this.getParent().getChildByTag(TAG_CYLINDER1_NODE);

				var rotate7 = cc.rotateTo(0.5,10);
				var rotate8 = cc.rotateTo(0.5,0);
				var seq1 = cc.sequence(cc.callFunc(function(){
					hand.addlefthand(cylinder1node, "#hand/hand_left", cc.p(-20,25),0.6);
				},this));
				cylinder1node.runAction(seq1);
				var show = new ShowTip1("量取200mL",25,cc.p(880,100));
				

				var spaw2 = cc.spawn(moveBack,rotate);
				var loadCyl1 = cylinder1node.getChildByTag(TAG_CYLINDER1);				
				var rotate1 = cc.rotateTo(0.5,10);
				var rotate2 = cc.rotateTo(1,0);
				
				var spawn1 = cc.sequence(rotate1,cc.delayTime(3.5),rotate2);
		
				cylinder1node.runAction(spawn1);

				var clyDtl = new cc.Sprite("#cly_dtl2.png");

				clyDtl.setPosition(loadCyl1.width + clyDtl.width * 0.5,loadCyl1.height * 0.5);
//				clyDtl.setOpacity(0);
				//clyDtl.setCascadeOpacityEnabled(true);
				loadCyl1.addChild(clyDtl);
				var fade1 = cc.fadeTo(2.5, 255);
				var delay = cc.delayTime(4.5);
				var delay2 = cc.delayTime(3.5);
				var fade2 = cc.fadeTo(0.5,0);
				var fade3 = cc.fadeTo(1,0);
				var sequence = cc.sequence(delay, fade2,cc.callFunc(function(){
					clyDtl.removeFromParent();
				},this));
				clyDtl.runAction(sequence);
				var clyLine = new cc.Sprite("#cly_line1.png");
				var spawn3=cc.spawn(cc.scaleTo(1.2,1.2),fade1);
				 clyLine.setOpacity(0);
				clyDtl.addChild(clyLine);
				clyLine.setPosition(clyDtl.width * 0.5, 5);
				clyLine.runAction(cc.sequence(spawn3,cc.moveBy(1.5,cc.p(0,clyDtl.height * 0.7+1)),fade3));	


				




                p.runAction(func);
				var seq = cc.sequence(cc.callFunc(function(){
					hand.addrighthand(this, "#hand/hand_right", cc.p(25,-25),0.6);
				}, this),spawn,delay2,spaw2,cc.callFunc(function(){
					hand.removehand(this, 1, 2);
					show.kill();
				}, this),cc.callFunc(this.flowNext, this));

				this.runAction(seq);					
			}
			if(action==K2){
			//	var kettle=this.getChildByTag(TAG_KETTLE);
				var move = cc.moveBy(1.5,cc.p(-140,-260));
				
				var rotate= cc.rotateTo(0.5,-60);
				var moveback=cc.moveBy(1,cc.p(140,260));
				var rotate1= cc.rotateTo(1,0);
				var spawn1 = cc.spawn(moveback,rotate1);
				var delay = cc.delayTime(2.5);
				var delay1 = cc.delayTime(0.5);

				p.runAction(func);
				
				var seq = cc.sequence(cc.callFunc(function(){
					hand.addrighthand(this, "#hand/hand_right", cc.p(25,-25),0.6);
				}, this),move,rotate,cc.spawn(delay,cc.bezierBy(2.5,[cc.p(-20,0),cc.p(-20,-20),cc.p(0,0)])),spawn1,cc.callFunc(function(){
					hand.removehand(this, 1, 2);
				}, this),cc.callFunc(this.flowNext,this));
				this.runAction(seq);
				
				var beakernode = this.getParent().getChildByTag(TAG_BEAKER_NODE);
				var beaker=beakernode.getChildByTag(TAG_BEAKER);
				//beaker.setCascadeOpacityEnabled(true);
				var fade2=cc.fadeTo(0.5,200);
				beaLine2 =beaker.getChildByTag(TAG_BEAKER_LINE);
				beaLine2.runAction(cc.sequence(cc.delayTime(1.5),fade2,cc.moveTo(1,cc.p(beaker.width*0+33,beaker.height *0.3+5))));

				
				
				break;
				
				

			}
			if(action==K3){
				
				var volumetricnode = this.getParent().getChildByTag(TAG_VOLUMETRIC_NODE);
				var volumetric=volumetricnode.getChildByTag(TAG_VOLUMETRIC);

				beaLine = volumetricnode.getChildByTag(TAG_BEAKER_LINE1);


				var scale=cc.scaleTo(1,0.26);



				beaLine.runAction(cc.sequence(cc.delayTime(2),cc.spawn(scale,cc.moveBy(4,cc.p(-1,volumetric.height * 0.1)))));

				var move = cc.moveBy(1.5,cc.p(-285,-200));
				var rotate= cc.rotateTo(0.5,-60);
				var moveback=cc.moveBy(1,cc.p(230,210));
				var rotate1= cc.rotateTo(1,0);
				var spawn1 = cc.spawn(moveback,rotate1);
				var delay = cc.delayTime(4);
				var delay1 = cc.delayTime(0.5);


				var seq = cc.sequence(cc.callFunc(function(){
					hand.addrighthand(this, "#hand/hand_right", cc.p(25,-25),0.6);
				}, this),move,rotate,delay,spawn1,cc.callFunc(function(){
					hand.removehand(this, 1, 2);
					show.kill();
				}, this),cc.callFunc(this.flowNext,this));
				var show = new ShowTip1("刻度线以下1-2厘米",25,cc.p(250,100));
				p.runAction(func);
				
				this.runAction(seq);
				
				break;


			}


			
			
		}
	},
	
	actionDone:function(p){
		var action = gg.flow.flow.action;
		var func = cc.callFunc(this.actionDone, this);
		switch(p.getTag()){
		case TAG_KETTLE:
			if (action==K1){




				var shuiliu = new cc.Sprite("#shuiliu.png");
				shuiliu.setAnchorPoint(1, 1);
				shuiliu.setScale(0);
				shuiliu.setRotation(60);
				shuiliu.setPosition(0, 172);
				p.addChild(shuiliu);
				var seq = cc.sequence(cc.delayTime(2),cc.scaleTo(0.5,1),cc.delayTime(1.8),cc.fadeTo(0.2,0),cc.callFunc(function(){
					shuiliu.removeFromParent();
				},this));
				shuiliu.runAction(seq);
			}
			if(action==K2){
				var shuiliu1 = new cc.Sprite("#shuiliu.png");
				shuiliu1.setAnchorPoint(1, 1);
				shuiliu1.setScale(0);
				shuiliu1.setRotation(60);
				shuiliu1.setPosition(10,173);
				p.addChild(shuiliu1);
				var seq = cc.sequence(cc.delayTime(2),cc.scaleTo(0.5,1),cc.delayTime(1.0),cc.fadeTo(0.2,0),cc.callFunc(function(){
					shuiliu1.removeFromParent();
				},this));
				shuiliu1.runAction(seq);
//				var beaker = this.getChildByTag(TAG_BEAKER1); 
//				var clyLine = new cc.Sprite("#cly_line1.png");
//				beaker.addChild(clyLine,1,TAG_SHOW);
//				clyLine.setPosition(beaker.width * 0.5, 0);
//				clyLine.runAction(cc.moveBy(1.2,cc.p(0,beaker.height * 0.6)));
//				var shuiliu = new cc.Sprite("#shuiliu.png");
//				shuiliu.setAnchorPoint(1, 1);
//				//shuiliu.setScale(0);
//				shuiliu.setRotation(60);
//				shuiliu.setPosition(0, 172);
//				p.addChild(shuiliu);
//				var seq = cc.sequence(cc.scaleTo(0.5,1),cc.delayTime(0.8),cc.fadeTo(0.2,0),cc.callFunc(function(){
//					shuiliu.removeFromParent();
//				},this));
//				shuiliu.runAction(seq);
//				var seq1 = cc.sequence(cc.delayTime(2),cc.moveTo(0.5,cc.p(550,120)));
//				beaker.runAction(seq1);
			}
			if(action==K3){
				var shuiliu1 = new cc.Sprite("#shuiliu.png");
				shuiliu1.setAnchorPoint(1, 1);
				shuiliu1.setScale(0);
				shuiliu1.setRotation(50);
				shuiliu1.setPosition(5,173);
				p.addChild(shuiliu1);
				var seq = cc.sequence(cc.delayTime(2),cc.scaleTo(0.5,1),cc.delayTime(3),cc.fadeTo(0.2,0),cc.callFunc(function(){
					shuiliu1.removeFromParent();
				},this));
				shuiliu1.runAction(seq);
				
				var cly_dtl3 = new cc.Sprite("#cly_dtl3.png");
				cly_dtl3.setAnchorPoint(1, 1);
				cly_dtl3.setOpacity(0);
				cly_dtl3.setRotation(60);
				cly_dtl3.setPosition(-20,160);
				p.addChild(cly_dtl3);
				var seq1 = cc.sequence(cc.delayTime(2),cc.fadeTo(0.5,255),cc.delayTime(3.0),cc.fadeTo(0.2,0),cc.callFunc(function(){
					cly_dtl3.removeFromParent();
				},this));
				cly_dtl3.runAction(seq1);
				
				var clyLine = new cc.Sprite("#cly_line1.png");
				var spawn3=cc.spawn(cc.scaleTo(0.2,0.4),cc.fadeTo(0.5, 150));
				clyLine.setOpacity(0);
				cly_dtl3.addChild(clyLine);
				clyLine.setPosition(cly_dtl3.width * 0.5+4, 5);
				clyLine.runAction(cc.sequence(cc.delayTime(2),spawn3,cc.moveBy(1.5,cc.p(0,cly_dtl3.height * 0.4-5)),cc.delayTime(1),cc.fadeTo(0.5, 0)));	

			
//				var jianshi = this.getChildByTag(TAG_JIANSHI_NODE);
//				jianshi.setCascadeOpacityEnabled(true);
//				var clyDtl = new cc.Sprite("#js.png");
//				clyDtl.setPosition(jianshi.width + clyDtl.width * 0.5,jianshi.height * 0.5);
//				clyDtl.setOpacity(0);
//				clyDtl.setCascadeOpacityEnabled(true);
//				jianshi.addChild(clyDtl);
//				var fade1 = cc.fadeTo(0.5, 255);
//				var delay = cc.delayTime(1.5);
//				var fade2 = cc.fadeTo(0.5,0);
//				var sequence = cc.sequence(fade1, delay, fade2);
//				clyDtl.runAction(sequence);
//				var clyLine = new cc.Sprite("#cly_line1.png");
//				clyLine.setScale(1.1);
//				clyDtl.addChild(clyLine);
//				clyLine.setPosition(clyDtl.width * 0.5, 0);
//				clyLine.runAction(cc.moveBy(1,cc.p(0,clyDtl.height * 0.8-32)));	

			}


			break;
		}
	},

	flowNext:function(){

		gg.flow.next();
		cc.log("下一步"+gg.flow.flow.tag);
	}

});